package cn.jhc.bookbrowser;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Created by luyanfei on 16-2-27.
 */
public class BookFragment extends Fragment {
    public static final String BOOK_TITLE = "book title";
    public static final String BOOK_DESCRIPTION = "book description";
    public static final String TOP_IMAGE = "top image";

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_book, container, false);
        Bundle arguments = getArguments();
        TextView titleView = (TextView) view.findViewById(R.id.txt_title);
        titleView.setText(arguments.getString(BOOK_TITLE));
        TextView descView = (TextView) view.findViewById(R.id.txt_desc);
        descView.setText(arguments.getString(BOOK_DESCRIPTION));
        ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
        Log.d("BookFragmentTag", "imageid:" + arguments.getInt(TOP_IMAGE));
        imageView.setImageResource(arguments.getInt(TOP_IMAGE));
        return view;
    }
}
